# 
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

include $(TOPDIR)/rules.mk

PKG_NAME:=glib
PKG_VERSION:=2.45.3
PKG_RELEASE:=2

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=https://download.gnome.org/sources/glib/2.45/glib-2.45.3.tar.xz
PKG_MD5SUM:=
DEPEND_libffi:=libffi-3.2.1

include $(INCLUDE_DIR)/package.mk

define Package/glib
  SECTION:=libs
  CATEGORY:=Libraries
  TITLE:=Command lines edition library
  DEPENDS:= +gettext +zlib +libffi
endef

define Package/glib/description
endef

define Build/Configure
	(cd $(PKG_BUILD_DIR); \
	export PATH=$(PATH):/home/zhou/NVMP/cross_compile/package/bluez_lib/glib-pc/bin; \
		$(TARGET_CONFIGURE_OPTS) \
		./configure \
		--prefix=/usr \
		--host=$(GNU_TARGET_NAME) \
		--target=$(GNU_TARGET_NAME) \
		LIBFFI_LIBS="-L$(STAGING_DIR)/usr/lib -lffi " \
		LIBFFI_CFLAGS="-I$(STAGING_DIR)/usr/include" \
		ZLIB_LIBS="-lz -L$(STAGING_DIR)/usr/lib/nvmp/libs" \
		ZLIB_CFLAGS="-I$(STAGING_DIR)/usr/include" \
		LDFLAGS=-L$(STAGING_DIR)/usr/lib  \
		CPPFLAGS=-I$(STAGING_DIR)/usr/include \
		glib_cv_stack_grows=yes \
		glib_cv_uscore=yes \
		ac_cv_func_posix_getpwuid_r=yes \
		ac_cv_func_posix_getgrgid_r=yes \
		CFLAGS="$(TARGET_CFLAGS) $(FPIC)" \
		--disable-selinux  --disable-xattr --disable-libelf --enable-shared=no \
	);
endef

TARGET_CPPFLAGS:=-I. -I.. $(TARGET_CPPFLAGS)

TARGET_CFLAGS += $(FPIC)

define Build/Compile
	$(MAKE) -C $(PKG_BUILD_DIR) \
		DESTDIR="$(PKG_INSTALL_DIR)" \
		all install
endef

define Build/InstallDev
	$(INSTALL_DIR) $(1)/usr/lib
	$(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib/
	$(INSTALL_DIR) $(1)/usr/include
	$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
	$(CP) $(PKG_INSTALL_DIR)/usr/lib/glib-2.0/include/glibconfig.h $(1)/usr/include/
endef

define Package/glib/install
endef

$(eval $(call BuildPackage,glib))
